<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
           function getSum(k1,k2)
           {
                  var sum = k1;
                  for(var  i=k1;i<=k2;i++)
                  {
                     sum+=i;
                  }
                  return sum;
           }
           console.log(getSum(4,40))
    </script>
</body>
</html>